package com.gopay.solution.dao.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.solution.domain.po.SsTransProfitDtl;

/**
 * 方案服务 返润方案明细表
 * 
 * @SsTransProfitDtlDAOImpl.java
 * @author wanggang
 * @2014-7-10 下午3:41:28 www.gopay.com.cn Inc.All rights reserved.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
@Repository("ssTransProfitDtlDAO")
public class SsTransProfitDtlDAOImpl extends SolutionRuleDtlDAOImpl<SsTransProfitDtl, Serializable> {

    @Override
    public SsTransProfitDtl getByPk(Serializable id) {
        return find(SsTransProfitDtl.class, id);
    }

    @Override
    public List<SsTransProfitDtl> listBySolutionId(long solutionId) {
        String hql = "from SsTransProfitDtl dtl where dtl.solutionId = :SolutionId order by dtl.sq";
        
        Map params = new HashMap();
        params.put("SolutionId", solutionId);
        
        return findByHql(hql, params);
    }

    @Override
    public boolean delBySolutionId(long solutionId) {
        List<SsTransProfitDtl> dtls = listBySolutionId(solutionId);
        if (dtls != null && dtls.size() > 0) {
            deleteAll(dtls);
        }
        return true;
    }

    @Override
    public List<SsTransProfitDtl> listBySoluIdAndIntTxnCd(long solutionId, String intTxnCd) {
        String hql = "from SsTransProfitDtl dtl where dtl.solutionId = :SolutionId and dtl.gopayIntTxnCd = :GopayIntTxnCd order by dtl.sq";

        Map params = new HashMap();
        params.put("SolutionId", solutionId);
        params.put("GopayIntTxnCd", intTxnCd);

        return findByHql(hql, params);
    }

    @Override
    public boolean delBySoluIdAndIntTxnCd(long solutionId, String intTxnCd) {
        List<SsTransProfitDtl> dtls = listBySoluIdAndIntTxnCd(solutionId, intTxnCd);
        if (dtls != null && dtls.size() > 0) {
            deleteAll(dtls);
        }
        return true;
    }

}
